<template>
  <div>
    <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>产品配置</el-breadcrumb-item>
        <el-breadcrumb-item>用户群组配置</el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>
    <basic-container>
      <avue-crud
        ref="crud"
        :data="data"
        v-model="form"
        :option="option"
        @on-load="getList"
        @refresh-change="refreshChange"
        @search-reset="from = {}"
        @search-change="searchChange"
        @row-update="rowUpdate"
        @row-save="rowSave"
         @row-del="rowDel"
      >
       <template slot="is_show" slot-scope="scope">
         <!-- <div>fdfdsf</div> -->
          <div >{{scope.row.operation}}</div>
        </template> 
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import { common } from "@/api/cat/httpRequest";
import { catUrl } from "@/config/env";
import {
  userGroup as baseURL,
  appPopup,
  getGroupList,
} from "@/api/cat/baseUrls";
export default {
  data() {
    return {
      radio: "1",
      page: {
        total: 0,
        pageSize: 10,
      },
      type: true,
      data: [],
      params: {},
      form: {},
      oldForm: {},
      // default: {
      //   orderByList: "create_time&ASC",
      // },
      option: {
        border: true,
        index: true,
        label: "序号",
        tip: true,
        viewBtn: false,
        editBtn: true,
        addBtn: true,
        delBtn: true,
        align: "center",
        headerAlign: "center",
        column: [
          {
            label: "用户群组名称",
            prop: "group_name",
            type: "input",
            search: false,
          },
          {
            label: "备注",
            prop: "remarks",
            type: "input",
            dicData: [
              { label: "可见", value: 1 },
              { label: "不可见", value: 0 },
            ],
            addDisplay: true,
          },
          {
            label: "最后操作信息",
            prop: "is_show",
            type: "input",
            slot:true,
            editDisplay: false,
            addDisplay: false,
          },
        ],
      },
    };
  },
  methods: {
    /**自定义修改方法,解决跳转路径回显问题 */
    // customEdit(scope) {
    //   console.info("tag", scope);
    //   this.oldForm = scope.row;
    //   this.$refs.crud.rowEdit(scope.row, scope.index);
    // },
    /**获取列表 */
    async getList() {
      this.loading = true;
      //清空表格列表
      this.data = [];
      //发送请求获取数据
      let response = await common(
        `${baseURL.pageAndParam}`,
        { ...this.params },
        this.page,
        "POST"
      );
      this.page = response.page;
      this.data = response.data;
      this.loading = false;
    },
    /**保存 */
    async rowSave(row, done, loading) {
      let params ={group_name:row.group_name,operation:this.$store.state.user.userInfo.username,remarks:row.remarks}
      let data = await common(`${baseURL.save}`, params, null, "POST");
      if (data == null) {
        loading();
        return;
      }

      this.getList();
      done();
    },
    /**修改 */
    async rowUpdate(row, index, done, loading) {
      //判断是否填写了跳转路径
      let params = {group_name:row.group_name, group_id: row.group_id, remarks:row.remarks };
      let data = await common(`${baseURL.update}`, params, null, "POST");
      if (data == null) {
        loading();
        return;
      }

      this.getList();
      done();
    },
    /**刷新 */
    refreshChange() {
      this.getList();
    },
    /**删除 */
    rowDel(row) {
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        type: "warning",
      })
        .then(async () => {
          let response = await common(
            `${baseURL.delete}`,
            { id: row.group_id },
            null,
            "GET"
          );
        })
        .then(() => {
          this.getList();
        });
    },
    /**搜索 */
    searchChange(params, done) {
      //   params.popup_name = `%${params.popup_name ? params.popup_name : ""}%`;
      this.params = params;
      this.page.currentPage = 1;
      this.getList();
      if (done) done();
    },
  },
  mounted() {
  },
  // async created() {
  //查询跳转页面列表
  // let { data } = await getConfigSkippaheType();
  // this.option.column[2].dicData = data.source;
  // },

  // async created() {
  //   //查询跳转页面列表
  //   let { data } = await common(appPopup.getSkippaheType, null, null, "GET");
  //   this.option.column[2].dicData = data;
  // },
};
</script>

<style>
</style>